
using System.Diagnostics;
using System.Threading;

namespace ThreadingIssues
{
    public class SimpleTask
    {
        public SimpleTask()
        {

        }
        public void RaceCondition(object o)
        {
            Console.WriteLine("[SimpleTask] RaceCondition");
            Trace.Assert(o is StateObject, "o must be of type StateObject");
            StateObject state = o as StateObject;

            int i = 0;
            while (true)
            {
                lock (state)
                {
                    state.ChangeState(i++);
                }
            }
        }
    }
}
